<?php
/**
 * name：表格NoData组件
 * user：sa0
 * date：2021/2/3 8:00 下午
 * @param $params
 * @param $template
 * @return string
 */
function smarty_function_no_data($params, $template): string
{
    if (count($params['data']) != 0) return '';
    $no_data = '<div class="sa0-no-data-wrapper"><div><img src="/assets/image/NoData.png" alt="no_data"></div><div>';
    switch ($params['type']) {
        case 'button':
            $no_data .= '<button onclick="';
            $no_data .= getContent($params);
            $no_data .= '</button>';
            break;
        case 'a':
            $no_data .= '<a href="';
            $no_data .= getContent($params);
            $no_data .= '</a>';
            break;
    }
    $no_data .= '</div></div>';
    return $no_data;
}

function getContent($params): string
{
    $content = $params['onclick'];
    $content .= '" class="layui-btn layui-btn-primary">';
    $content .= $params['text'];
    return $content;
}
